package com.example.springboot.common;

import lombok.Data;

/**
 * ClassName:Result
 * Package:com.example.springboot.common
 * Description:
 * Result类，用来封装返回结果
 * @Author: Gao
 * @Create: 2023/2/1 - 17:12
 */
@Data
public class Result {


    private String code;
    private String msg;
    private Object data;

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode("200");
        result.setData(data);
        return result;
    }

    public static Result success() {
        Result result = new Result();
        result.setCode("200");
        return result;
    }
    public static Result error(String msg) {
        Result result = new Result();
        result.setCode("-1");
        result.setMsg(msg);
        return result;
    }

    public static Result error(String code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

}
